package thread.pool;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class MultiThreadingUsingAnnonymousClassByRunable {
	
	public static void method(Object obj) {
		File file=new File("/home/tabkidsadmin/hello1.txt");
		File file1=new File("/home/tabkidsadmin/");
		String q[]=file1.list();
		System.out.println(q.length);
		String s="hello Vibhanshu.";
		try {
			FileOutputStream fileOutputStream=new FileOutputStream(file);
			byte b[]=s.getBytes();
			fileOutputStream.write(b);
			fileOutputStream.close();
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
synchronized(obj){
			
			((Thread) obj).start();
			
		}
	}
	
	public static void main(String[] args) {
		Runnable r1 = new Runnable() {
			
			@Override
			public void run() {
				System.out.println("First Tasks...");
			}
		};
		Runnable r2 = new Runnable() {
			
			@Override
			public void run() {
				System.out.println("Second Tasks..");
			}
		};
		
		
		Thread t1 = new Thread(r1);
		Thread t2 = new Thread(r2);
		method(t1);
		
		for (int i = 0; i < 50; i++) {
			System.out.println(i);
		}
		method(t2);
		
		
		
			}


	
	
}
